package com.lehuo.util;

import java.sql.DriverManager;
import java.sql.SQLException;

import com.mysql.jdbc.Connection;

public class ConnUtil {
	static final String driverName="com.mysql.jdbc.Driver";    //�������
	static final String userName="root";                         //�û���
	static final String userPasswd="123456";                      //����
	static final String dbName="lehuoquan";                          //��ݿ���
	static final String tableName="user";                     //��ݿ����
	static final String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd
			+"&useUnicode=true&characterEncoding=gbk";
			                         
	public static Connection getConnection(){
		Connection connection=null;
		try {
			Class.forName(driverName).newInstance();
			connection=(Connection)DriverManager.getConnection(url);
			System.out.println("数据库连接成功");
		} catch (InstantiationException | SQLException | IllegalAccessException | ClassNotFoundException e) {
			e.printStackTrace();
			System.out.println("数据库连接失败");
		}
		return connection;
	}

}
